package com.qf.student.service.impl;

import com.qf.student.dao.AdminMapper;
import com.qf.student.entity.Admin;
import com.qf.student.entity.Teacher;
import com.qf.student.dao.TeacherMapper;
import com.qf.student.response.R;
import com.qf.student.service.ITeacherService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2022-11-21
 */
@Service
public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> implements ITeacherService {

    @Autowired
    private TeacherMapper teacherMapper;

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public R getTeacherInfo(Integer userId) {
        Admin admin = adminMapper.selectById(userId);
        if (admin == null) {
            return R.createFAIL("登录信息有误，请重新登录");
        }

        List<Teacher> teachers = teacherMapper.selectList(null);
        return R.createSuccess(teachers);
    }
}
